import 'package:flutter/material.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

class LaksaWebsocket extends StatefulWidget {
  final String title;
  final WebSocketChannel channel;

  LaksaWebsocket({Key key, @required this.title, @required this.channel})
      :super(key: key);

  @override
  _LaksaWebsocketState createState() => new _LaksaWebsocketState();
}

class _LaksaWebsocketState extends State<LaksaWebsocket> {

  build(BuildContext context) =>
      new Scaffold(
          appBar: new AppBar(
            title: new Text(widget.title),
          ),
          body: new StreamBuilder(
            stream: widget.channel.stream,
            builder: (context, snapshot) {
              print(snapshot.data);
            },
          )
      );

  @override
  void dispose() {
    widget.channel.sink.close();
    super.dispose();
  }


}